<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="../../../assets/docs.css" rel="stylesheet" type="text/css" media="screen" />
<title>MooTools 1.3 Documentation - Types/URI.Relative</title>
</head>

<body>
  <div class="doc">
    <div class="methods">
      <h4 class="menu-item"><a href="#URI">URI</a></h4>
      <div class="menu-item"><a href="#URI:toAbsolute">toAbsolute</a></div>
      <div class="menu-item"><a href="#URI:toRelative">toRelative</a></div>
    </div>
    <div class="l-border r-border span-15 content">
      <h1 id="URI"><a href="#URI">Type: URI</a></h1>
      <p class="description">Extends the <a href="../../../docs/more/Types/URI.html">URI</a> class to add methods for computing relative and absolute urls.</p>
      <h2 id="URI:toAbsolute"><a href="#URI:toAbsolute">URI Method: toAbsolute</a></h2>
      <p class="description">Returns the absolute path for a given url (i.e. a path beginning with '/'). If a different schemes or hosts are used, it returns the full url.</p>
      <h3>Syntax</h3>
      <pre class="javascript">myURI.<span class="me1">toAbsolute</span><span class="br0">(</span><span class="br0">[</span>base<span class="br0">]</span><span class="br0">)</span>;
</pre>
      <h3>Arguments</h3>
      <ol>
        <li>base - (<em>mixed</em>, optional) - either an instance of <em>URI</em> or a <em>string</em> (which will be passed to <em>URI</em>) that contains the base location for the path.</li>
      </ol>
      <h3>Returns</h3>
      <ul>
        <li> <em>string</em> - the absolute path beginning with '/'.</li>
      </ul>
      <h2 id="URI:toRelative"><a href="#URI:toRelative">URI Method: toRelative</a></h2>
      <p class="description">Returns the relative path for a given url (i.e. a path that might include '../' for example). If a different schemes or hosts are used, it returns the full url.</p>
      <h3>Syntax</h3>
      <pre class="javascript">myURI.<span class="me1">toRelative</span><span class="br0">(</span><span class="br0">[</span>base<span class="br0">]</span><span class="br0">)</span>;
</pre>
      <h3>Arguments</h3>
      <ol>
        <li>base - (<em>mixed</em>, optional) - either an instance of <em>URI</em> or a <em>string</em> (which will be passed to <em>URI</em>) that contains a location that is relative to <em>myURI</em>.</li>
      </ol>
      <h3>Example</h3>
      <pre class="javascript"><span class="kw2">var</span> uri1 = <span class="kw2">new</span> URI<span class="br0">(</span><span class="st0">'http://www.test.com/this/is/a/path.html'</span><span class="br0">)</span>;
<span class="kw2">var</span> uri2 = <span class="kw2">new</span> URI<span class="br0">(</span><span class="st0">'http://www.test.com/this/is/an/adjacent/path.html'</span><span class="br0">)</span>

uri1.<span class="me1">toRelative</span><span class="br0">(</span>uri2<span class="br0">)</span>; <span class="co1">//returns "../../a/path.html"</span>
</pre>
      <h3>Returns</h3>
      <ul>
        <li> <em>string</em> - the relative path.</li>
      </ul>
    </div>
  </div>
<script type="text/javascript" src="../../../assets/mootools-core-1.3.js"></script>
<script type="text/javascript" src="../../../assets/mootools-more-smoothscroll.js"></script>
<script type="text/javascript" src="../../../assets/doc-assist.js"></script>
</body>
</html>
